<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('不合格品处理')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">

                    <div class="layui-inline">
                        <label class="layui-form-label">ASN编号</label>
                        <div class="layui-input-inline">
                            <!--<input type="text" class="layui-input" name="zjr" id="zjr"/>-->
                            <input type="text" name="asnbh" id="asnbh" placeholder="ASN编号" lay-verify="required" autocomplete="off" class="layui-input "/>
                        </div>
                    </div>
                      <div class="layui-inline inline-search-btn">
                       <a class="layui-btn layui-btn-normal" data-type="reload">搜索</a>
                   </div>
                </form>
                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>


                <!--列表-->
               <!-- <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>-->
                <div class="group-button tpl-button" id="toolbar">
                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
</body>


<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script th:inline="javascript">
    $("form input[type=text]").each(function () {
        this.value = $.trim(this.value);

        $(document).ready(function () {//通用方法去输入框前后空格
            $("form").on("change", function () {
                $("form input[type=text]").each(function () {
                    this.value = $.trim(this.value);
                });
            })
        });
    });

    console.log("我来了！！ ");
    $(".moreBtn").on("click",function () {
        $(".moreSearch").toggle();
    })

    var functions = [[${functions}]];
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'tablebutton'], function () {
        /*var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        zzpUtils.select2({
            elem: ".js-data-example-ajax",
            url: "/wmsrrailwayplatform/list"
        });*/
        /*window.operateEvent = {
            "click .layui-btn-primary": function (e, value, row, index) {
                alert(row.mc);
            },
            "click #ruku": function (e, value, row, index) {//入库
                rukuDialog(row.id);
            },
            "click #chuku": function (e, value, row, index) {//出库
                chukuDialog(row.id);
            },
            "click #daochu": function (e, value, row, index) {//导出
                daochuDialog(row.id);
            },
        };*/


        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
        var $table;
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                //入库
                Warehousing: function (data) {
                    rukuDialog(data.row.id);
                },
                //入库
                getlibrary: function (data) {
                    chukuDialog(data.row.id);
                },
                //导出
                /*exportEvent: function(data){
                    if (data.row != undefined) {
                        var ids = [];
                        alert(data.row.id)
                        ids.push(data.row.id);
                        /!*
                        * 以下是将ids和对象拼接在一起
                        * *!/
                        var str=zzpUtils.getFormJson($("#searchForm"));
                        var object2 = Object.assign({ids: ids}, str);
                        /!*将条件查询和ids传到后台*!/
                        zzpUtils.outputXslx({
                            url:"/wmsfailedlibrary/getOutPutList",
                            data:JSON.stringify(object2)
                        });

                    } else {
                        var arr=[];
                        var $rows = $table.bootstrapTable('getSelections');
                        if ($rows.length >0) {
                            arr = $.map($rows, function (row) {
                                return row.id;
                            })
                        }
                        /!*
                         * 以下是将ids和对象拼接在一起
                         * *!/
                        var str=zzpUtils.getFormJson($("#searchForm"));
                        var object2 = Object.assign({ids: arr}, str);
                        /!*将条件查询和ids传到后台*!/
                        zzpUtils.outputXslx({
                            url:"/wmsfailedlibrary/getOutPutList",
                            data:JSON.stringify(object2)
                        });

                    }
                }*/

                exportEvent: function(data){
                    var arr=[];
                    var $rows = $table.bootstrapTable('getSelections');
                    if ($rows.length >0) {
                        arr = $.map($rows, function (row) {
                            return row.id;
                        })
                    }
                    /*
                     * 以下是将ids和对象拼接在一起
                     * */
                    var str=zzpUtils.getFormJson($("#searchForm"));
                    var object2 = Object.assign({ids: arr}, str);
                    /*将条件查询和ids传到后台*/
                    zzpUtils.outputXslx({
                        url:"/wmsfailedlibrary/getOutPutList",
                        data:JSON.stringify(object2)
                    });
                }




            }
        });

        //不合格出库
        function chukuDialog(id) {
            zzpUtils.dialog({
                title: "不合格出库",
                type: 2,
                content: "/Disqualification/unqualified?id=" + id,
                area: ['100%', '100%'], //设置dialog大小，也可以不设置，
                end: function () {//修改成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }
        //不合格入库
        function rukuDialog(id) {
            zzpUtils.dialog({
                title: "不合格入库",
                type: 2,
                content: "/Disqualification/Warehousing?id=" + id,
                area: ['100%', '100%'], //设置dialog大小，也可以不设置，
                end: function () {//修改成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }


        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: true,
            isOperate: true,
            functions: functions.tableBtn,
            url: '/wmsfailedlibrary/list',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'ckmc',
                title: '仓库'
            }, {
                field: 'hzmc',
                title: '货主'
            }, {
                field: 'gysmc',
                title: '供应商名称'
            },{
                field: 'asnbh',
                title: 'ASN编号'
            }, {
                field: 'dycgdbh',
                title: 'PO编号'
            }, {
                field: 'zjdh',
                title: '质检单号'
            }, {
                field: 'show_asnlx',
                title: 'ASN类型'
            }, {
                field: 'cjsj',
                title: '创建时间'
            }, {
                field: 'shwcsjTime',
                title: '收货完成时间'
            }/*,{
                field:'caozuo',
                title: '操作',
                events:operateEvent,
                formatter:operateFormatter
            }*/],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            /*定义表格右侧按钮*/
            operateFormatter: operateFormatter
        });

        function operateFormatter(value, row, index) {
            var button = '<a class="tooltip2" id="tooltip' + row.id + '" data-tooltip-content="#tool' + row.id + '" id="btn_start"><i class="layui-icon layui-icon-more"></i></a>'
                + '<div class="tooltip_templates">'
                + '<span id="tool' + row.id + '">';
            for (var i = 0; i < functions.tableBtn.length; i++) {
                var btn = '<a class="layui-btn layui-btn-sm layui-btn-warm" lay-event="' + functions.tableBtn[i].event + '">'
                    + functions.tableBtn[i].name
                    + '</a>';

                    /*if (functions.tableBtn[i].name == '入库' || functions.tableBtn[i].name == '出库' || functions.tableBtn[i].name == '导出') {*/
                        button += btn;
                    /*}*/

            }
            button += '</span>'
                + '</div>';
            return button;

        };
        /*function operateFormatter(value, row, index) {
            return [
                '<a class="layui-btn layui-btn-xs" id="ruku">入库</a>',
                '<a class="layui-btn layui-btn-xs" id="chuku">出库</a>',
                '<a class="layui-btn layui-btn-radius layui-btn-xs layui-btn-normal" id="daochu">导出</a>',
            ].join('')
        }*/

        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })
    });
</script>
</html>